package com.tim.third.demo.db.h2;

import com.tim.third.YmlUtils;
import com.tim.util.DbUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.env.PropertySource;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;

/**
 * @author litianlin
 * @date 2023/11/23 15:12
 * @description:
 */
@Slf4j
public class H2Connect {

    public static void main(String[] args) {
        testH2Connection();
    }
    public static void testH2Connection(){
        try {
            String url = "jdbc:h2:tcp://localhost:9092/./h2";
            String username = "sa";
            String password = "";
            Connection conn = DbUtils.getConnection(url, username, password);
            ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM INFORMATION_SCHEMA.USERS ");
            System.out.println(DbUtils.rsToInsert(rs));
            conn.isClosed();
        } catch (Exception e) {
            log.error("", e);
        }
    }
}
